import { Pipe } from '@angular/core';
import { DictConstants } from './data.dictionary';

@Pipe({
  name: 'translate'
})

export class DataTranslatePipe {

  constructor() { }

  transform(value, type, defaultValue) {
    let dicts = DictConstants.dicts[type];

    for (let index in dicts) {
      if(dicts[index].value == value){
        return dicts[index].name;
      }
    }

    return typeof defaultValue == 'undefined' ? '' : defaultValue;
  }
}
